home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / TEXTGADG.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  3KB  |  95 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1992, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.5  $
  6. //
  7. // Definition of text gadget class TGadget.
  8. //----------------------------------------------------------------------------
  9. #if !defined(OWL_TEXTGADG_H)
  10. #define OWL_TEXTGADG_H
  11.  
  12. #if !defined(OWL_GADGETWI_H)
  13. # include <owl/gadgetwi.h>
  14. #endif
  15.  
  16. #if !defined(OWL_GADGET_H)
  17. # include <owl/gadget.h>
  18. #endif
  19.  
  20. #if defined(BI_NAMESPACE)
  21. namespace OWL {
  22. #endif
  23.  
  24. // Generic definitions/compiler options (eg. alignment) preceeding the 
  25. // definition of classes
  26. #include <services/preclass.h>
  27.  
  28. //
  29. // class TTextGadget
  30. // ~~~~~ ~~~~~~~~~~~
  31. // When constructing the text gadget specify how many characters you want
  32. // room for and how the text should be aligned horizontally.
  33. //
  34. // The inner bounds are computed by multiplying the number of characters by
  35. // the maximum character width.
  36. //
  37. class _OWLCLASS TTextGadget : public TGadget {
  38.   public:
  39.     enum TAlign {Left, Center, Right};
  40.  
  41.     TTextGadget(int id = 0, TBorderStyle = Recessed, TAlign = Left,
  42.                 uint numChars = 10, const char far* text = 0,
  43.                 TFont* font = 0 /*new TGadgetWindowFont*/);
  44.    ~TTextGadget();
  45.  
  46.     // Return a copy of gadget's text
  47.     //
  48.     const char far*   GetText() const;
  49.  
  50.     // Makes a copy of the text
  51.     //
  52.     void              SetText(const char far* text);
  53.  
  54.   protected:
  55.     // Override virtual methods defined in TGadget
  56.     //
  57.     void    Paint(TDC& dc);
  58.     void    GetDesiredSize(TSize &size);
  59.     void    Invalidate();
  60.  
  61.   // Data members -- will become private
  62.   //
  63.   protected_data:
  64.     char far* Text;       // new'd copy of the text for this gadget
  65.     uint      TextLen;    // strlen of the above text
  66.     TAlign    Align;      // Alignment: left, center or right
  67.     uint      NumChars;   // Number of chars to reserve space for
  68.     TFont*    Font;       // display font
  69.  
  70.   private:
  71.     // Hidden to prevent accidental copying or assignment
  72.     //
  73.     TTextGadget(const TTextGadget&);
  74.     TTextGadget& operator =(const TTextGadget&);
  75. };
  76.  
  77. // Generic definitions/compiler options (eg. alignment) following the 
  78. // definition of classes
  79. #include <services/posclass.h>
  80.  
  81. #if defined(BI_NAMESPACE)
  82. } // namespace OWL
  83. #endif
  84.  
  85. // --------------------------------------------------------------------------
  86. // Inline implementation
  87. //
  88.  
  89. //
  90. inline const char far* TTextGadget::GetText() const {
  91.   return Text;
  92. }
  93.  
  94. #endif  // OWL_TEXTGADG_H
  95.